package org.chatty;

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.OutputStream;

import javax.sound.sampled.AudioFileFormat;
import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;

public abstract class Util {
	private Util() {}

	public static void write( 
		byte audioData[]
		, AudioFormat audioFormat
		, AudioFileFormat.Type audioFileFormat_type
		, OutputStream outputStream 
	) throws IOException {

		AudioInputStream audioInputStream = new AudioInputStream(
			new ByteArrayInputStream( audioData )
			, audioFormat
			, audioData.length / audioFormat.getFrameSize()
		);

		AudioSystem.write( audioInputStream, audioFileFormat_type, outputStream );
	}   
}
